package com.interview.ujiuye4;

class MyThreadAA extends Thread{
    public void run(){
        try{
            Thread.sleep(1000);
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
        
    }
}
class MyThread1 implements Runnable{
    public synchronized void run(){
        try{
            wait(5000); // TIMED_WAITING 记时等待
            //wait();//WAITING  等待
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}


public class Demo10 {
    public static void main(String[] args) {
        MyThreadAA my = new MyThreadAA();
        System.out.println("线程状态my:new:"+my.getState());
        my.start();
        System.out.println("线程状态my:start:"+my.getState());

        MyThread1 my1 = new MyThread1();
        Thread t1 = new Thread(my1);
        t1.start();
        try{
            Thread.sleep(2000);
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
        System.out.println("线程状态my:terminated:"+my.getState());
        System.out.println("线程状态t1:"+t1.getState());
        while(Thread.activeCount() > 2){

        }
        System.out.println("线程等待结束状态t1:"+t1.getState());
    }
}